//
//  QZFriendVC.m
//  shortvideoplay
//
//  Created by tikeios_002 on 2024/6/18.
//

#import "QZFriendVC.h"
#import "YSYHasNetwork.h"
#import "JXCategoryTitleView.h"
#import "JXCategoryView.h"
#import "QZFriendDetailsVC.h"
@interface QZFriendVC ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
@property(strong, nonatomic)NSArray * listArr;
@property(strong, nonatomic)NSMutableArray * nameArr;
@property (nonatomic, strong) JXCategoryTitleView *myCategoryView;
@property (nonatomic, strong) JXCategoryListContainerView * listContainerView;
@end

@implementation QZFriendVC

-(void)showTextViewNavViewTo1{
    NSMutableArray * showTextViewNavViewNameArrTo1 = [NSMutableArray new];
    UIView * showTextViewNavViewViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewNavViewViewTo1.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:showTextViewNavViewViewTo1];
    UILabel * showTextViewNavViewLabelTo1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger showTextViewNavViewNumberTo1 = arc4random_uniform(20);
    NSLog(@"：%ld", (long)showTextViewNavViewNumberTo1);
    showTextViewNavViewLabelTo1.text = [NSString stringWithFormat:@"%ld",(long)showTextViewNavViewNumberTo1];
    [showTextViewNavViewLabelTo1 addSubview:showTextViewNavViewLabelTo1];
    
    UIImageView * showTextViewNavViewLabelTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [showTextViewNavViewViewTo1 addSubview:showTextViewNavViewLabelTo2];
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.mm_drawerController setEnableGesture:NO];
    if(self.listArr.count == 0){
        [SVProgressHUDTool showWithStatus:nil];
        [self pageRequest];
    }
}
- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
}
#pragma mark -初始化
- (NSMutableArray *)nameArr{
    if(_nameArr == nil){
        _nameArr = [NSMutableArray new];
    }
    return _nameArr;
}
#pragma mark -网络区域
- (void)pageRequest{
    [SVProgressHUDTool showWithStatus:nil];
    KMutableDic(params);
    KWeakSelf
    [YBNetBase videoTypeListRequest:params successBlock:^(NSDictionary * _Nonnull data, NSInteger code, NSString * _Nonnull msg) {
        if(code == 200){
            weakSelf.listArr = data[@"my_list"];
            for (NSDictionary * dic in weakSelf.listArr) {
                if([dic[@"name"] isEqualToString:@"其他"]){
                    [weakSelf.nameArr addObject:dic[@"name"]];
                }else{
                    [weakSelf.nameArr insertObject:dic[@"name"] atIndex:0];
                }
            }
            [weakSelf addTitleView];
        }else{
            [SVProgressHUDTool showWithStatus:nil];
            [YBMsgPop showPop:msg];
        }
    }];
}
- (void)addTitleView{
    self.myCategoryView = [[JXCategoryTitleView alloc] init];
    self.myCategoryView.backgroundColor = [UIColor clearColor];
    self.myCategoryView.frame = CGRectMake(0, kStatusBarHeight+2, KScreen_W, 40);
    self.myCategoryView.titleFont = FontMedium(14);
    self.myCategoryView.titleSelectedFont = FontBold(16);
    self.myCategoryView.titles = self.nameArr;
    self.myCategoryView.titleColorGradientEnabled = YES;
    self.myCategoryView.titleColor = COLOR_ALPH(255, 255, 255, 0.77);
    self.myCategoryView.titleSelectedColor = [UIColor whiteColor];
    self.myCategoryView.delegate = self;
    
    
    self.listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
    self.listContainerView.frame = CGRectMake(0, KNav_H, KScreen_W, KScreen_H-KTab_H-KNav_H);
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:self.listContainerView];
       UILabel * oldshowSSSSTip3 = [[UILabel alloc]init];
    oldshowSSSSTip3.clipsToBounds = YES;
    oldshowSSSSTip3.text = @"kass显示区";
    oldshowSSSSTip3.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip3.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip3.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip3.hidden = YES;
    [self.view addSubview:oldshowSSSSTip3];
    [self.view addSubview:self.myCategoryView];
    

    self.myCategoryView.listContainer = self.listContainerView;
//    [self.myCategoryView reloadData];
}
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
    
}
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
    return self.nameArr.count;
}
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    QZFriendDetailsVC *controller = [[QZFriendDetailsVC alloc] init];
    controller.typeName = self.nameArr[index];
    return controller;
}
@end
